package com.myq.note.controller;

import com.myq.note.po.Note;
import com.myq.note.po.Result;
import com.myq.note.service.NoteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/noteBook")
public class NoteController {


    @Autowired
    public NoteService noteService;

    //查看状态为1或者2（回收站）笔记
    @GetMapping("/findAllNote.action")
    public Result findAllNote(Note note){

        Result<List<Note>>  result = noteService.findAllNote(note);
        return result;
    }

    @GetMapping("/findById.action")
    public Result findById(Note note){
        //System.out.println(note);
        Result<Note>  result = noteService.findById(note.getNote_id());
        return result;
    }

    //创建笔记
    @PostMapping("/createBook.action")
    public Result createNote(Note note){

        Result result = noteService.createNote(note);


        return result;
    }
    //修改笔记
    @PostMapping("/updateNote.action")
    public Result updateNote(Note note){


        Result result = noteService.updateNote(note);


        return result;
    }
    //删除笔记到回收站
    @GetMapping("/deleteNote.action")
    public Result deleteNote(Note note){
        //System.out.println(note);

        Result result = noteService.deleteNote(note);


        return result;
    }

    /**
     * 确定从回收站删除
     */
    @GetMapping("/deleteSureNote.action")
    public Result deleteSureNote(Note note){

        Result result = noteService.deleteSureNote(note);

        return result;
    }




}
